package com.css.devops.domain;

import lombok.Getter;

/**
 * 构建结果
 */
@Getter
public enum BuildResult {

	FAILURE("FAILURE", "失败"),
	SUCCESS("SUCCESS", "成功"),
	ABORTED("ABORTED", "终止"),
	UNKNOWN("UNKNOWN", "构建中");
	
	/**
	 * 代码
	 */
	private String code;
	/**
	 * 名称
	 */
	private String name;

	BuildResult(String code, String name) {
		this.code = code;
		this.name = name;
	}
	
	
	/**
	 * 根据类型获取BuildResult
	 * @param result
	 * @return
	 */
	public static BuildResult getBuildResult(String result) {
		for(BuildResult br : BuildResult.values()) {
			if(br.getCode().equals(result)) {
				return br;
			}
		}
		return BuildResult.SUCCESS;
	}
}
